package com.jiali.backend.controller;

import com.jiali.backend.common.ResponseResult;
import com.jiali.backend.controller.request.ReviewRequest;
import com.jiali.backend.model.Review;
import com.jiali.backend.service.ReviewService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/review")
public class ReviewController {
    @Resource
    private ReviewService reviewService;

    @PostMapping("/create")
    public ResponseResult<Review> createReview(
            @RequestBody ReviewRequest reviewRequest,
            HttpServletRequest request) {
        return reviewService.createReview(reviewRequest, request);
    }

    @GetMapping("/get")
    public ResponseResult<Review> getReviewByOrderId(
            @RequestParam Integer orderId) {
        return reviewService.getReviewByOrderId(orderId);
    }
}